import request from '@/utils/request.js'

// 获取文章详情的api接口 id为文章的ID
export const getArticleInfoAPI = function (id) {
  return request.get('/v1_0/articles/' + id)
}

// 关注作者的api接口  target文章作者的id
export const follweUserAPI = function (target) {
  return request.post('/v1_0/user/followings', { target })
}

// 取消关注作者的api接口  id文章作者的id
export const unfollweUserAPI = function (id) {
  return request.delete('/v1_0/user/followings/' + id)
}

// 给文章点赞的api接口  target文章的id
export const likeArticleAPI = function (target) {
  return request.post('/v1_0/article/likings', { target })
}
// 取消点赞的api接口  id文章的id
export const dislikeArticleAPI = function (id) {
  return request.delete('/v1_0/article/likings/' + id)
}

// 根据文章id 请求文章评论的接口
export const getCmtListAPI = function (source, offset) {
  return request.get('/v1_0/comments', {
    params: {
      type: 'a',
      // 文章id
      source,
      // 偏移量，用来分页
      offset
    }
  })
}

// 发表评论
export const publishCommentAPI = function (target, content) {
  return request.post('/v1_0/comments', {
    target,
    content
  })
}

// 给评论点赞的api接口  target评论的id
export const likeCommentAPI = function (target) {
  return request.post('/v1_0/comment/likings', { target })
}

// 取消点赞的api接口  id文章的id
export const dislikeCommentAPI = function (id) {
  return request.delete('/v1_0/comment/likings/' + id)
}
